#ifndef __WEB_PAGE_H__
#define __WEB_PAGE_H__

#include "./uiobject.h"
#include "web/webhost.h"

namespace MiniUI
{

class WinView;
class WebPage : public UIObject,
                public Creator<WebPage>,
                public TypeObject<WebPage>
{
public:
    friend class Creator<WebPage>;
protected:
    WebPage();
    ~WebPage();
public:
    HRESULT SendMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
    virtual bool RenderTo(Graphics& graphics, const Type::MiniRect& rcRender, const uint8 blendValue);
    bool LoadURL(const char* szURL);
    virtual void SetWinView(WinView* pWinView);
protected:
    virtual bool DblClk(const Type::MiniPoint& pt, MouseButton button, uint keyState, bool& bHandled);
    virtual bool MouseDown(const Type::MiniPoint& pt, MouseButton button, uint keyState, bool& bHandled);
    virtual bool MouseUp(const Type::MiniPoint& pt, MouseButton button, uint keyState, bool& bHandled);
    virtual bool MouseMove(const Type::MiniPoint& pt, uint keyState, bool& bHandled);
    virtual void MouseLeave();
    virtual bool MouseWheel(const Type::MiniPoint& pt, uint keyState, int16 zDelta, bool& bHandled);
    virtual void VisibleChange(bool bVisible);
    virtual void FocusChange(bool bFocus);
    virtual void Resize(const Type::MiniSize& szOld, const Type::MiniSize& szNew);
private:
    void OnWindowActivate(const WinView* sender, bool bActivate);
    void OnWebInvalidate(WebHost* pWebHost, Type::MiniRect* rcDirty);
private:
    WebHost* m_pWebhost;
};

}

#endif